import axios from '@/utils/request';

/**
 * 查询设备列表
 */
export async function GetDeviceList(params) {
  const res = await axios.post('/Device/QueryDeviceByCondition', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 获取guid
 */
export async function GetGuid(id) {
  const res = await axios.get('/Attchment/GetGuid');
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 新增设备
 */
export async function AddDevice(params) {
  const res = await axios.post('/Device/AddDevice', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 删除设备
 */
export async function DelDevice(params) {
  const res = await axios.post(`/Device/DeleteDevice?id=${params.id}`);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 新增设备图片上传
 */
export async function UploadFile(params) {
  const res = await axios.post('/Attchment/UploadFile', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 获取设备详情
 */
export async function GetDevceDetail(params) {
  const res = await axios.get(`Device/QueryDeviceById?id=${params.id}`);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 *  修改设备
 */
export async function EditDevice(params) {
  const res = await axios.post('/Device/UpdateDevice', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}


/**
 *  查询产品列表
 */
export async function getProductList(params) {
  const res = await axios.post('/Product/QueryProductByCondition', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 新增产品
 */
export async function AddProduct(params) {
  const res = await axios.post('/Product/AddProduct', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 获取所有规格
 */
export async function GetAllModels() {
  const res = await axios.get('/ProductSpecItem/GetAllModels');
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}


/**
 * 获取产品详情
 */
export async function QueryProductById(params) {
  const res = await axios.get(`/Product/QueryProductById?id=${params.id}`);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}


/**
 * 获取字典值
 */
export async function QueryAllChildDictViewByCode(params) {
  const res = await axios.get(`Dict/QueryAllChildDictViewByCode?code=${params.code}`);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}



/**
 *  修改产品
 */
export async function UpdateProduct(params) {
  const res = await axios.post('/Product/UpdateProduct', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 删除设备
 */
export async function DeleteProduct(params) {
  const res = await axios.post(`/Product/DeleteProduct?id=${params.id}`);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}




/**
 * 查询仓库列表
 */
export async function QueryWarehouseByCondition(params) {
  const res = await axios.post('/WareHouse/QueryWarehouseByCondition', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}


/**
 * 新增仓库
 */
export async function AddWarehouse(params) {
  const res = await axios.post('/WareHouse/AddWarehouse', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}



/**
 * 获取仓库详情
 */
export async function QueryWarehouseById(params) {
  const res = await axios.get(`/WareHouse/QueryWarehouseById?id=${params.id}`);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 *  修改产品
 */
export async function UpdateWarehouse(params) {
  const res = await axios.post('/WareHouse/UpdateWarehouse', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}


/**
 * 删除设备
 */
export async function DeleteWarehouse(params) {
  const res = await axios.post(`/WareHouse/DeleteWarehouse?id=${params.id}`);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}


/**
 * 查询库存列表
 */
export async function QueryInStockByCondition(params) {
  const res = await axios.post('/InStock/QueryInStockByCondition', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}



/**
 * 查询产品列表
 */
export async function QueryProductJoinItemByCondition(params) {
  const res = await axios.post('/Product/QueryProductJoinItemByCondition', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}



/**
 * 新增仓库
 */
export async function AddInStock(params) {
  const res = await axios.post('/InStock/AddInStock', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}




/**
 * 获取仓库详情
 */
export async function QueryInStockById(params) {
  const res = await axios.get(`/InStock/QueryInStockById?id=${params.id}`);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}


/**
 * 查询所有用户信息列表
 */
export async function AllPersonnel(params) {
  const res = await axios.post('/User/QueryUserByCondition', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}





/**
 *  修改产品
 */
export async function UpdateInStock(params) {
  const res = await axios.post('/InStock/UpdateInStock', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}




/**
 * 删除设备
 */
export async function DelInStock(params) {
  const res = await axios.post(`/InStock/DelInStock?id=${params.id}`);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}


/**
 *  修改产品
 */
export async function AuitInStock(params) {
  const res = await axios.post('/InStock/AuitInStock', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}


/**
 *  查询明细列表
 */
export async function QueryStockByCondition(params) {
  const res = await axios.post('/Stock/QueryStockByCondition', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}


/**
 *  查询入库明细列表
 */
export async function QueryInStockItemByCondition(params) {
  const res = await axios.post('/InStockItem/QueryInStockItemByCondition', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 *  查询出库明细列表
 */
export async function QueryStockItemByCondition(params) {
  const res = await axios.post('/Stock/QueryStockItemByCondition', params);
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

